<#
 #   It is recommended to test the script on a local machine for its purpose and effects. 
 #   ManageEngine Endpoint Central will not be responsible for any 
 #   damage/loss to the data/setup based on the behavior of the script.

 #   Description: Script is designed to Test the internet connection in the end machine without ping
 #   Configuration Type - COMPUTER
 #>
 
function Test-InternetConnection {
    $url = "http://www.google.com"  # You can use any reliable URL
    try {
        $request = [System.Net.WebRequest]::Create($url)
        $request.Timeout = 5000  # Set timeout in milliseconds
        $response = $request.GetResponse()
        if ($response.StatusCode -eq [System.Net.HttpStatusCode]::OK) {
            Write-Output "Internet connection is active."
            return $true
        }
    } catch {
        Write-Output "Internet connection is not available."
        return $false
    }
}

# Check internet connection
Test-InternetConnection